<?php echo $this->load->view('meta'); ?>
<script type="text/javascript">
$(function() {
	$("#full_calendar a[rel]").overlay( 
	    { 
	      onBeforeLoad: function() {  
	        // grab wrapper element inside content  
	        var wrap = this.getContent().find("div.wrap"); 
	        wrap.load( 
	          this.getTrigger().attr("href") 
	        );  
	      },  
	      expose: {
				color: '#BAD0DB',
				opacity: 0.7,
				closeSpeed:10
		  } 
	    });

});
</script>
<?php echo $this->load->view('header'); ?>

<!-- overlayed element --> 
<div class="overlay" id="overlay"> 
 
    <!-- the external content is loaded inside this tag --> 
    <div class="wrap"></div> 
 
</div>
<div id="right_side">
<div id="full_calendar">

<table class="full">
	<tr>
		<td colspan='2'><a href='<? echo site_url("calendar/monthly/" . date('n',$date) . '/' . date("Y",strtotime("-1 year",$date)) )?>'><span style="font-size:10px">Previous Year</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='<? echo site_url("calendar/monthly/" . date("n",strtotime("-1 month",$date)) . '/' . date("Y",strtotime("-1 month",$date)) )?>'><span style="font-size:10px">Previous Month</span></a></td><td colspan='3'><span style="font-size:18px;"><?=date("F Y",$date)?></span></td>
		
		<td colspan='2'><a href='<? echo site_url("calendar/monthly/" . date("n",strtotime("+1 month",$date)) . '/' . date("Y",strtotime("+1 month",$date)) )?>'><span style="font-size:10px">Next Month</span></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='<? echo site_url("calendar/monthly/" . date("n",$date) . '/' . date("Y",strtotime("+1 year",$date)) )?>'><span style="font-size:10px">Next Year</span></a></td</tr>
	<tr>
		<th class="calendar_center">Sunday</th>
		<th class="calendar_center">Monday</th>
		<th class="calendar_center">Tuesday</th>
		<th class="calendar_center">Wednesday</th>
		<th class="calendar_center">Thursday</th>
		<th class="calendar_center">Friday</th>
		<th class="calendar_center">Saturday</th>
	</tr>
	<? foreach ($dates as $day): ?>
	<tr>
	<? for ($i=0;$i<7;$i++): ?>
		<td><div class='containerr'><div id="<?=$day[$i]?>" class='date'><?=$day[$i]?></div>
		<? if(isset($events)): ?>
			<? if(array_key_exists($day[$i],$events)): ?>
					<? foreach($events[$day[$i]] as $current): ?>
						<? $a = (strtotime("$current[end]") - strtotime("$current[start]"))/(60*60*24);?>
						<? if($a<1 && $a>0):?>
			<a href='<?php echo site_url("calendar/event/$current[id]");?>' rel="#overlay"><div class='event'><?=date("g:ia",strtotime("$current[start]"))?> <?=$current['name']?></div></a>
						<? elseif($a==0): ?>
			<a href='<?php echo site_url("calendar/event/$current[id]");?>' rel="#overlay" ><div class='event_all_day'><?=$current['name']?></div></a>
						<? else :?>
							<? if($day[$i]==date("j",strtotime("$current[start]"))): ?>
			<a href='<?php echo site_url("calendar/event/$current[id]");?>' rel="#overlay" ><div class='event_spanning' style="padding:0px;"><?=date("g:ia",strtotime("$current[start]"))?> <?=$current['name']?></div></a>
							<? else: ?>
			<a href='<?php echo site_url("calendar/event/$current[id]");?>' rel="#overlay" ><div class='event_spanning' style="padding:0px;"><?=$current['name']?></div></a>
							<? endif;?>
						<? endif; ?>
					<? endforeach; ?>
			</div></td>
					
				
				<? else: ?>
			</div></td>
				<? endif; ?>
			</div></td>
			<? else: ?>
			</div></td>
			<? endif; ?>
			
			<? endfor; ?>
		</tr>
			<? endforeach; ?>

</table>
</div>
</div>
<?=$this->load->view('footer');?>